package com.lxw.search.controller;

import com.lxw.api.search.EsCourseSearchApi;
import com.lxw.framework.domain.course.CoursePub;
import com.lxw.framework.domain.course.TeachplanMediaPub;
import com.lxw.framework.domain.search.CourseSearchParam;
import com.lxw.framework.model.response.QueryResponseResult;
import com.lxw.search.service.CourseSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("search/course")
public class CourseSearchController implements EsCourseSearchApi {
    @Autowired
    private CourseSearchService courseSearchService;
    @Override
    @GetMapping("list/{page}/{size}")
    public QueryResponseResult searchCourse(@PathVariable("page") Integer page,
                                            @PathVariable("size") Integer size,
                                            CourseSearchParam courseSearchParam) {
        return courseSearchService.searchCourse(page,size,courseSearchParam);
    }
    @Override
    @GetMapping("/getall/{id}")
    public Map<String, CoursePub> getAllCourseById(@PathVariable("id") String courseId) {
        return courseSearchService.getAllCourseById(courseId);
    }
    @Override
    @GetMapping(value="/getmedia/{teachplanId}")
    public TeachplanMediaPub getmedia(@PathVariable("teachplanId")String teachplanId) {
        return courseSearchService.getmedia(teachplanId);
    }
}
